package com.demo.function.mybatisplus;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.demo.dao.mapper.TenantMapper;
import com.demo.model.entity.Tenant;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TenantService {

    @Resource
    private TenantMapper tenantMapper;

    /**
     * 自动添加租户id
     * @param name 名称
     * @return 租户数据集合
     */
    public List<Tenant> query(String name) {
        LambdaQueryWrapper<Tenant> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Tenant::getName, name);

        return tenantMapper.selectList(wrapper);
    }

    /**
     * 不使用租户id查询
     * @param name 名称
     * @return 租户数据集合
     */
    public List<Tenant> queryWithoutTenant(String name) {
        return tenantMapper.queryWithoutTenant(name);
    }
}
